#Indicator '************************************************************** '* Leader of the MACD (LeaderOfTheMACD.txt) '* by Jeremy Williams '* May 14, 2008 '* '* Adapted from Technical Analysis of Stocks and Commodities '* July 2008 '* '* Summary: '* '* This indicator calculates a oscillator which is used in '* conjuction with the traditional MACD indicator. For more '* information see "Leader of the MACD" in the July 2008 issue of Technical '* Analysis of Stocks and Commodities. '* '* Parameters: '* '* ShortPeriods - Specifies the number of periods for the fast '* moving average calculation '* '* LongPeriods- Specifies the number of periods for the slow '* moving average calculation '************************************************************** #Param "ShortPeriods" , 12 #Param "LongPeriods" , 26 Dim ShortEMA As Single Dim ShortDiff As Single Dim ShortEMA2 As Single Dim Indicator1 As Single Dim LongEMA As Single Dim LongDiff As Single Dim LongEMA2 As Single Dim Indicator2 As Single Dim Leader As Single ' Calculate the EMA's ShortEMA = EMA(ShortPeriods) LongEMA = EMA(LongPeriods) ' Calculate the differences between close and the EMA's ShortDiff = C - ShortEMA LongDiff = C - LongEMA ' Calculate the EMA of the differences ShortEMA2 = EMA(ShortDiff,ShortPeriods) LongEMA2 = EMA(LongDiff,LongPeriods) ' Combine the base EMA with the EMA of the differences to ' reduce lag Indicator1 = ShortEMA + ShortEMA2 Indicator2 = LongEMA + LongEMA2 ' Calculate the value of the Leader indicator by differencing ' the two indicators Leader = Indicator1 - Indicator2 ' Plot the Indicator Plot("MACDLeader",Leader) ' Return the value calculated by the indicator Return Leader